package com.homework3;

import com.sun.xml.internal.ws.api.ha.StickyFeature;

public class CommonResp<E> {
    private Integer code;
    private String msg;
    private E data;

    public CommonResp(Integer code, String msg, E data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public CommonResp(String msg) {
        this.msg = msg;
    }

    public CommonResp(E data) {
        this.data = data;
        this.msg = "";
        this.code = 200;
    }
    public static<S> CommonResp<S> sucess(S data){
        return new CommonResp<>(data);
    }
    public static<S> CommonResp<S> error(String msg){
        return new CommonResp<>(msg);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public E getData() {
        return data;
    }

    public void setData(E data) {
        this.data = data;
    }
}
